<!DOCTYPE html>
<html class="x-admin-sm">
{include file='public/header'}
<script src="/admin/xadmin/lib/layui/upload.js" charset="utf-8"></script>
<style>
    .layui-form-label{
        width: 120px;
    }
    .layui-input-block{
        margin-left: 150px;
    }
</style>
<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="javascript:void(0)">首页</a>
            <a href="javascript:void(0)">公众号管理</a>
            <a><cite>公众号设置</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" id="reload" title="刷新">
            <i class="layui-icon" style="line-height:30px"><i class="iconfont">&#xe6aa;</i></i>
        </a>
    </div>
    <div class="x-body">
        <form class="layui-form" lay-filter="formAjax">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>公众号类型
                </label>
                <div class="layui-input-block">
                    <input type="radio" name="type" value="0" title="订阅号" checked>
                    <input type="radio" name="type" value="1" title="服务号">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>是否认证
                </label>
                <div class="layui-input-block">
                    <input type="radio" name="is_auth" value="0" title="未认证" checked>
                    <input type="radio" name="is_auth" value="1" title="已认证">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>原始ID
                </label>
                <div class="layui-input-block">
                    <input type="text" name="original_id" placeholder="原始ID" required="required"
                        lay-verify="required" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>微信号
                </label>
                <div class="layui-input-block">
                    <input type="text" name="wechat_number" placeholder="微信号" required="required"
                        lay-verify="required" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>公众号名称
                </label>
                <div class="layui-input-block">
                    <input type="text" name="name" placeholder="公众号名称" required="required"
                        lay-verify="required" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>AppId 
                </label>
                <div class="layui-input-block">
                    <input type="text" name="app_id" placeholder="AppId" required="required"
                        lay-verify="required" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>AppSecret 
                </label>
                <div class="layui-input-block">
                    <input type="text" name="app_secret" placeholder="AppSecret" required="required"
                        lay-verify="required" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>IP白名单 
                </label>
                <div class="layui-input-block">
                    <input type="text" name="ip_white_list" placeholder="ip_white_list" disabled autocomplete="off" class="layui-input" value="" />
                </div>
            </div>
            
           
            <input type="hidden" name="id" id="id" value="" />
            <button id="submitData" class="layui-btn" lay-submit lay-filter="submitData" style="margin-left: 150px;">保存</button>
        </form>
    </div>
    <script>
        let params = {
            editUrl: '/cps/officialAccount/edit',
            detailUrl: '/cps/officialAccount/detail',
        }
        layui.use(["form", "layer"], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;
            Ajax(params.detailUrl,{},'get').then(result =>{
                form.val("formAjax",result.data);
            });
            form.on('submit(submitData)', function(data){
                var formData = data.field
                let url = params.editUrl
                Ajax(url,formData).then(data =>{
                    if (data.code === 200) {
                        layer.msg(data.message, {
                            icon: 6
                        });
                    }
                });
                return false
            });
        })

    </script>
</body>

</html>